import api from "../../apis/activity";

Component({
  properties: {},
  data: {
    layout: []
  },
  methods: {
    more() {
      wx.switchTab({
        url: "/pages/activity/index"
      })
    }
  },
  lifetimes: {
    async attached() {
      const tagMapping = ["科创", "生活", "就业", "社团", "讲座", "展览", "实验招募"]
      let data = (await api.getSuggestion()).map(e => ({
        id: e["id"],
        poster: e["poster"] ?? "/assets/poster.png",
        title: e["name"],
        tags: [tagMapping[e["type_id"]]],
      }));
      this.setData({
        layout: data
      })
    }
  }
});
